﻿using furion.blog.Domain.MySQL;
using furion.blog.Domain.Shared.Dto.User;
using furion.blog.EntityFramework.Core;
using Furion;
using Furion.DependencyInjection;
using Mapster;
using MapsterMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace furion.blog.Application.CustomMapper
{
    public class UserMapper : Mapper, IRegister, ISingleton
    {


        public void Register(TypeAdapterConfig config)
        {
            config.ForType<UserProfileUpdateDto, User>()
            .Map(dest => dest.Avatar, source => source.Avatar)
            .Map(dest => dest.RealName, source => source.RealName)
            .Map(dest => dest.NickName, source => source.NickName)
            .Map(dest => dest.Phone, source => source.Phone)
            .Map(dest => dest.Email, source => source.Email)
            .Map(dest => dest.Sex, source => source.Sex)
            .Map(dest => dest.UpdatedBy, source => source.UpdatedBy)
            .Map(dest => dest.UpdatedTime, source => DateTime.Now)
            .IgnoreNonMapped(true);


            config.ForType<UserUpdateDto, User>()
            .Map(dest => dest.RealName, source => source.RealName)
            .Map(dest => dest.NickName, source => source.NickName)
            .Map(dest => dest.Phone, source => source.Phone)
            .Map(dest => dest.Email, source => source.Email)
            .Map(dest => dest.Sex, source => source.Sex)
            .Map(dest => dest.RoleId, source => source.RoleId)
            .Map(dest => dest.DeptId, source => source.DeptId)
            .Map(dest => dest.Avatar, source => source.Avatar)
            .Map(dest => dest.Remark, source => source.Remark)
            .Map(dest=>dest.UpdatedBy,source=>source.UpdatedBy)
            .Map(dest=>dest.UpdatedTime,source=>source.UpdatedTime)
            .IgnoreNonMapped(true);

        }
    }
}
